#include <stdio.h>
#include <stdlib.h>
#include <scene.h>

int scene_info(const char *fname);

int main(int argc, char **argv)
{
	int i, num_done = 0;

	setenv("RENDY_PLUGIN_PATH", "../plugins/obj", 1);

	for(i=1; i<argc; i++) {
		if(argv[i][0] == '-' && argv[i][2] == 0) {
			switch(argv[i][1]) {
			case 'h':
				printf("usage: %s <scene file>\n", argv[0]);
				return 0;

			default:
				fprintf(stderr, "unrecognized option: %s. Try -h for help\n", argv[i]);
				return 1;
			}
		} else {
			scene_info(argv[i]);
			num_done++;
		}
	}

	if(!num_done) {
		fprintf(stderr, "you must specify a scene file\n");
		return 1;
	}

	return 0;
}

int scene_info(const char *fname)
{
	struct scene *s;

	if(!(s = scn_create())) {
		perror("scn_create failed");
		return -1;
	}

	if(scn_read(s, fname) == -1) {
		fprintf(stderr, "failed to read scene file: %s\n", fname);
		scn_free(s);
		return -1;
	}

	scn_print_info(s, stdout);
	scn_free(s);
	return 0;
}
